# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html


class DianyingPipeline(object):

    def __init__(self):
        self.file_fp = open("./my_data.text", "w", encoding="utf-8")
        # import csv
        # self.csv_fp = csv.DictWriter(self.file_fp, ("author", "content"))
        # self.csv_fp.writeheader()

    def process_item(self, item, spider):
        self.file_fp.write(str(item) + "\n")
        return item

    def __del__(self):
        self.file_fp.close()